package com.xingmang.admin.controller;

import com.xingmang.admin.service.ThirdAppService;
import com.xingmang.common.constant.PageEntity;
import com.xingmang.common.constant.ResultBean;
import com.xingmang.common.dto.admin.ThirdAppInfoDTO;
import com.xingmang.common.dto.admin.ThirdAppPageDTO;
import com.xingmang.common.dto.admin.ThirdAppSaveDTO;
import com.xingmang.common.dto.admin.ThirdAppUpdateDTO;
import com.xingmang.common.vo.admin.ThirdAppPageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @auther: hansom
 * @Version: 1.0
 * @create 2023/6/19 15:55
 */
@RestController
@RequestMapping("/admin/third_app")
@Api(tags = "第三方应用")
public class ThirdAppController {

    @Resource
    private ThirdAppService thirdAppService;

    @PostMapping("page")
    @ApiOperation("分页")
    public ResultBean<PageEntity<ThirdAppPageVO>> page(@RequestBody @Validated ThirdAppPageDTO dto){
        return thirdAppService.page(dto);
    }

    @PostMapping("save")
    @ApiOperation("新增")
    public ResultBean save(@RequestBody @Validated ThirdAppSaveDTO dto){
        return thirdAppService.save(dto);
    }

    @PostMapping("update")
    @ApiOperation("修改")
    public ResultBean update(@RequestBody @Validated ThirdAppUpdateDTO dto){
        return thirdAppService.update(dto);
    }

    @PostMapping("delete")
    @ApiOperation("删除")
    public ResultBean delete(@RequestBody @Validated ThirdAppInfoDTO dto){
        return thirdAppService.delete(dto);
    }
}
